#-*-coding: utf-8 -*-

"""Here are the data structures of Daemon: Projects and Jobs.

Them implements the Interop Router concepts, where a project contains
many jobs and the application source code. Each job contains the input data
file to a instance of the application.

But, in the code, these classes are more independents, and a project don't
contain the job really, only is associate with its. This choice left some
tasks simpler.

"""

class Job(object):
    """Implements the job data.
    
    Each job contains information about the its data file, processing status,
    the project which belongs and is name.
    
    """
        
    def __init__(self, fields):
        """The Job Constructor. Set the values using the 
        information of the table Projects in Database.
        
        Keyoword arguments:
        
        fields -- a list with the job id, the id of project which jobs belongs,
        a job name,
        the data file,
        and the job status, that here is always equal to 1
        
        """
        
        self.id = fields[0]
        self.projectId = fields[1]
        self.name = fields[2]
        self.dataFile = fields[3]
        self.status = 1
        
            
class Project(object):
    """Implements the project data.
    
    Each project contains information about the program execution and
    the program source code.
    
    """

    def __init__(self, id, fields):
        """Set the values using the information of the table Projects in Database.
        
        Keyoword arguments:
        
        id -- a string with the project id in the Interop Router.
        
        fields -- a list with the number of processors required for the project
        and the parameters os program call.
        
        The attribute sourceCode is create in run time, after the class __init__.
        
        """
        
        self.id = id
        self.reqProcessors = fields[0]
        self.parameters = fields[1]
    
        
